// 收藏夹相关
// noinspection JSUnusedLocalSymbols

import {MyCache} from "@ginstone/common-utils/dist/src/utils/MyCache";
import {NukeApi} from "@ginstone/nga-api/dist/src/method/NukeApi";
import {FavorAddParam, FavorFolderListParam} from "@ginstone/nga-api/dist/src/params/NukeParams";

export default {
    namespaced: true,
    state: {
        cache: new MyCache(),

    },
    mutations: {
        method(state, payload) {

        },
    },
    actions: {
        method: ({dispatch, commit, state, rootGetters}, payload) => {

        },
        favorTopicAdd: ({dispatch, commit, state, rootGetters}, {folderId, tid, pid}) => {
            const client = rootGetters["Account/getClient"]();
            return NukeApi.favorTopicAdd(client, new FavorAddParam(folderId, tid, pid)).then(res => {
                state.cache.clear()
                return res;
            })
        },
        favorFolderList: ({dispatch, commit, state, rootGetters}, {force, userId, page}) => {
            const client = rootGetters["Account/getClient"]();
            userId = userId ? userId : client.userId
            const method = () => NukeApi.favorFolderList(client, new FavorFolderListParam(userId, page))
            return state.cache.use({userId, page}, method, force)
        },
    },
    getters: {},
}